Skip to content

fix(opencode): use relative SDD prompt paths - #1252

Merged
Alan-TheGentleman merged 4 commits into
Gentleman-Programming:mainfrom
decode2:fix/issue-723-relative-prompt-paths-v2
Jul 23, 2026
Merged

fix(opencode): use relative SDD prompt paths#1252
Alan-TheGentleman merged 4 commits into
Gentleman-Programming:mainfrom
decode2:fix/issue-723-relative-prompt-paths-v2

Conversation

@decode2

@decode2 decode2 commented Jul 13, 2026

Copy link
Copy Markdown
Contributor

Linked Issue

Closes #723


PR Type

  • type:bug - Bug fix (non-breaking change that fixes an issue)
  • type:feature - New feature (non-breaking change that adds functionality)
  • type:docs - Documentation only
  • type:refactor - Code refactoring (no functional changes)
  • type:chore - Build, CI, or tooling changes
  • type:breaking-change - Breaking change (fix or feature that changes existing behavior)

Summary

  • Generate OpenCode SDD prompt references as portable relative paths instead of machine-specific absolute paths.
  • Keep prompt resolution deterministic across single- and multi-profile generated settings.

Changes

File / Area What Changed
internal/components/sdd Generate relative prompt paths and update profile injection coverage.
internal/components/golden_test.go Normalize golden generation expectations for relative paths.
testdata/golden/sdd-opencode-multi-settings.golden Update deterministic generated JSON output.

Test Plan

Passed:

  • go test ./internal/components/sdd/...
  • go test ./internal/components -run '^TestGoldenSDD_OpenCode_Multi$'
  • go test ./internal/components
  • git diff --check

Runtime validation: N/A. The affected output is deterministic generated JSON and is covered by focused unit and golden tests; there is no separate runtime boundary.


Automated Checks

The repository checks will run on this PR.


Contributor Checklist

  • PR is linked to an issue with status:approved
  • PR stays within 400 changed lines, or has an approved exception
  • The appropriate type:* label is applied
  • Required tests pass
  • Documentation is updated if necessary
  • Commits follow Conventional Commits
  • Commits do not include Co-Authored-By trailers

Notes for Reviewers

Size: 9 files, +128/-50 (178 changed lines), under the 400-line review budget.

Summary by CodeRabbit

  • Bug Fixes

    • Improved SDD profile and sub-agent prompt references so generated opencode.json overlays and inline prompts use stable, settings-relative {file:...} paths instead of machine-specific absolute paths.
    • Ensures config prompt resolution follows XDG-config conventions and avoids embedding temporary/home directories.
  • Tests

    • Updated golden and integration tests to assert relative prompt references and verify outputs do not contain local absolute paths.
    • Added/expanded coverage for shared prompt reference generation and fallback behavior, including multi-mode injection scenarios.

@decode2

decode2 commented Jul 13, 2026

Copy link
Copy Markdown
Contributor Author

Maintainers, please add the type:bug label. The contributor account does not have permission to apply labels.

@coderabbitai

coderabbitai Bot commented Jul 13, 2026

Copy link
Copy Markdown

Review Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Repository UI

Review profile: ASSERTIVE

Plan: Pro Plus

Run ID: 59663286-4bac-4709-9dc7-0554b9495f7e

📥 Commits

Reviewing files that changed from the base of the PR and between 6ddf8d1 and f23b4de.

📒 Files selected for processing (1)
  • internal/components/sdd/inject_test.go

📝 Walkthrough

Walkthrough

SDD profile overlays and OpenCode prompt injection now generate settings-relative {file:...} references. A shared helper resolves these paths, callers pass settingsPath, and tests verify generated settings do not contain temporary home directories.

Changes

Portable prompt reference generation

Layer / File(s) Summary
Shared prompt reference helper
internal/components/sdd/prompts.go, internal/components/sdd/prompts_test.go
Adds SharedPromptFileRef, uses the configured OpenCode config root, and tests relative-reference generation and fallback behavior.
Overlay and injection integration
internal/components/sdd/profiles.go, internal/components/sdd/inject.go
Passes settingsPath through overlay generation and replaces absolute prompt references with shared relative references.
Integration and portability validation
internal/components/sdd/*_test.go, internal/components/golden_test.go, internal/cli/sync_test.go
Updates callers and assertions to validate relative references and generated settings without temporary home paths.

Estimated code review effort: 3 (Moderate) | ~20 minutes

Possibly related PRs

Suggested reviewers: alan-thegentleman

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 44.44% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title clearly matches the main change: making OpenCode SDD prompt paths relative and portable.
Linked Issues check ✅ Passed The changes address #723 by replacing machine-specific prompt paths with relative references and a fallback for non-relativizable cases.
Out of Scope Changes check ✅ Passed The extra code and test updates all support portable prompt-path generation and related overlay behavior; no unrelated scope stands out.
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@decode2
decode2 force-pushed the fix/issue-723-relative-prompt-paths-v2 branch from ff49243 to 2242051 Compare July 13, 2026 18:07

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Caution

Some comments are outside the diff and can’t be posted inline due to platform limitations.

⚠️ Outside diff range comments (1)
internal/components/sdd/profiles_test.go (1)

778-797: 🎯 Functional Correctness | 🔵 Trivial | ⚡ Quick win

Assert portability independently of the production helper.

The test computes expectedRef with the same SharedPromptFileRef used by GenerateProfileOverlay, so a regression that reintroduces absolute home paths can make both sides agree. Also assert that generated references are relative and contain no home path.

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@internal/components/sdd/profiles_test.go` around lines 778 - 797, Update the
test around GenerateProfileOverlay and its phase loop to validate portability
independently of SharedPromptFileRef: assert each generated prompt reference is
relative and does not contain the home path before or alongside comparing
expectedRef. Keep the existing expected-reference comparison, but ensure the
assertions would fail if GenerateProfileOverlay emits an absolute home-based
path.
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Outside diff comments:
In `@internal/components/sdd/profiles_test.go`:
- Around line 778-797: Update the test around GenerateProfileOverlay and its
phase loop to validate portability independently of SharedPromptFileRef: assert
each generated prompt reference is relative and does not contain the home path
before or alongside comparing expectedRef. Keep the existing expected-reference
comparison, but ensure the assertions would fail if GenerateProfileOverlay emits
an absolute home-based path.

ℹ️ Review info
⚙️ Run configuration

Configuration used: Repository UI

Review profile: ASSERTIVE

Plan: Pro Plus

Run ID: 917aaee2-f391-4db7-843a-71f771119398

📥 Commits

Reviewing files that changed from the base of the PR and between ff49243 and 2242051.

⛔ Files ignored due to path filters (1)
  • testdata/golden/sdd-opencode-multi-settings.golden is excluded by !testdata/**
📒 Files selected for processing (9)
  • internal/cli/sync_test.go
  • internal/components/golden_test.go
  • internal/components/sdd/inject.go
  • internal/components/sdd/inject_test.go
  • internal/components/sdd/profiles.go
  • internal/components/sdd/profiles_lifecycle_test.go
  • internal/components/sdd/profiles_test.go
  • internal/components/sdd/prompts.go
  • internal/components/sdd/prompts_test.go

@dnlrsls dnlrsls left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

SharedPromptFileRef is still not portable for OpenCode's supported XDG layout. SettingsPath can be $XDG_CONFIG_HOME/opencode/opencode.json, while SharedPromptDir remains $HOME/.config/opencode/prompts/sdd. On Unix this can generate a relative path containing the original home/user topology, and on Windows different config and home volumes make filepath.Rel fail and abort injection.

Please derive settings and shared prompt locations from one resolved config-root model, or otherwise handle roots that cannot produce a portable relative reference. A focused test for absolute XDG_CONFIG_HOME plus Windows different-volume behavior would establish the contract. The standard OpenCode and Kilocode layouts otherwise look correct.

@decode2
decode2 force-pushed the fix/issue-723-relative-prompt-paths-v2 branch from 2242051 to 6ddf8d1 Compare July 21, 2026 02:53

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 1

🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In `@internal/components/sdd/inject_test.go`:
- Around line 2388-2391: Update the expected prompt value in the test assertion
to use the existing SharedPromptFileRef symbol instead of a hardcoded path
string, preserving the comparison and failure message so path separators remain
platform-independent.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Repository UI

Review profile: ASSERTIVE

Plan: Pro Plus

Run ID: 9b13106d-814f-4a34-bdfa-d97f97eee299

📥 Commits

Reviewing files that changed from the base of the PR and between 2242051 and 6ddf8d1.

⛔ Files ignored due to path filters (1)
  • testdata/golden/sdd-opencode-multi-settings.golden is excluded by !testdata/**
📒 Files selected for processing (10)
  • internal/cli/sync_test.go
  • internal/components/golden_test.go
  • internal/components/sdd/inject.go
  • internal/components/sdd/inject_test.go
  • internal/components/sdd/issue557_test.go
  • internal/components/sdd/profiles.go
  • internal/components/sdd/profiles_lifecycle_test.go
  • internal/components/sdd/profiles_test.go
  • internal/components/sdd/prompts.go
  • internal/components/sdd/prompts_test.go

Comment thread internal/components/sdd/inject_test.go Outdated
@decode2

decode2 commented Jul 21, 2026

Copy link
Copy Markdown
Contributor Author

Updated in 6ddf8d18. Prompt references now honor the configured OpenCode root and fall back to an absolute slash-normalized path when the settings and prompt roots cannot be relativized. The tests use independent expected paths and cover the filepath.Rel failure contract.

The full Go suite, vet, Windows runtime, and E2E checks pass. This is ready for re-review. The only remaining required check is the maintainer-applied type:bug label.

@decode2 decode2 added the type:bug Bug fix label Jul 22, 2026
In OpenCode settings (and derivative adapters such as Kilo Code), prompt paths
for SDD phases previously used absolute paths (/home/devel/.gentle-ai/...). This caused
issues in containerized, remote, or multi-user environments where /home/devel differs.

Updated prompt reference injection to use relative prompt file paths relative to
the agent settings file, and updated TestInjectKilocodeSubagentPromptsUseRelativePath
to verify using SharedPromptFileRef for cross-platform path separator safety.

Fixes Gentleman-Programming#723

@Alan-TheGentleman Alan-TheGentleman left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Independent final review passed on the exact current candidate.

Direct current-main merge-tree and binary-patch proofs agree, the path fallback remains safe across configured roots and Windows-style paths, generated assets are consistent, focused/package tests pass, and every required non-AI check is green.

@Alan-TheGentleman
Alan-TheGentleman merged commit fc5dfe2 into Gentleman-Programming:main Jul 23, 2026
15 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

type:bug Bug fix

Projects

None yet

Development

Successfully merging this pull request may close these issues.

fix(opencode): avoid absolute prompt paths in generated settings

3 participants